"use strict";(self.webpackChunkpromptmanager=self.webpackChunkpromptmanager||[]).push([[2909],{87843:function(e,n,t){t.d(n,{r:function(){return u}});var r,i=t(72791),a=["title","titleId"];function o(){return o=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},o.apply(this,arguments)}function s(e,n){if(null==e)return{};var t,r,i=function(e,n){if(null==e)return{};var t,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}function l(e,n){var t=e.title,l=e.titleId,u=s(e,a);return i.createElement("svg",o({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"iconify iconify--simple-icons",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 24 24",ref:n,"aria-labelledby":l},u),t?i.createElement("title",{id:l},t):null,r||(r=i.createElement("path",{fill:"currentColor",d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515a.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0a12.64 12.64 0 0 0-.617-1.25a.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057a19.9 19.9 0 0 0 5.993 3.03a.078.078 0 0 0 .084-.028a14.09 14.09 0 0 0 1.226-1.994a.076.076 0 0 0-.041-.106a13.107 13.107 0 0 1-1.872-.892a.077.077 0 0 1-.008-.128a10.2 10.2 0 0 0 .372-.292a.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127a12.299 12.299 0 0 1-1.873.892a.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028a19.839 19.839 0 0 0 6.002-3.03a.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419c0-1.333.956-2.419 2.157-2.419c1.21 0 2.176 1.096 2.157 2.42c0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419c0-1.333.955-2.419 2.157-2.419c1.21 0 2.176 1.096 2.157 2.42c0 1.333-.946 2.418-2.157 2.418Z"})))}var u=i.forwardRef(l);t.p},28065:function(e,n,t){t.d(n,{r:function(){return u}});var r,i=t(72791),a=["title","titleId"];function o(){return o=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},o.apply(this,arguments)}function s(e,n){if(null==e)return{};var t,r,i=function(e,n){if(null==e)return{};var t,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||(i[t]=e[t]);return i}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(i[t]=e[t])}return i}function l(e,n){var t=e.title,l=e.titleId,u=s(e,a);return i.createElement("svg",o({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"iconify iconify--simple-icons",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 24 24",ref:n,"aria-labelledby":l},u),t?i.createElement("title",{id:l},t):null,r||(r=i.createElement("path",{fill:"currentColor",d:"M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zm1.271 0a2.527 2.527 0 0 1 2.521-2.52a2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zm0 1.271a2.528 2.528 0 0 1 2.521 2.521a2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zm10.122 2.521a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zm-1.268 0a2.528 2.528 0 0 1-2.523 2.521a2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zm-2.523 10.122a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zm0-1.268a2.527 2.527 0 0 1-2.52-2.523a2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z"})))}var u=i.forwardRef(l);t.p},52909:function(e,n,t){t.d(n,{p:function(){return U}});var r=t(4942),i=t(1413),a=t(29439),o=t(20890),s=t(64554),l=t(53767),u=t(27480),c=t(48550),d=t(24518),p=t(20068),f=t(99259),m=t(81918),h=t(61889),x=t(39281),g=t(94721),v=t(79836),Z=t(56890),_=t(35855),j=t(53994),b=t(53382),y=t(56125),w=t(16088),O=t(1252),q=t(30563),S=t(72791),k=t(72426),z=t.n(k),A=t(38399),P=t(54184),C=t.n(P),M=t(6608),R=t(56030),E=t(12705),I=t(7077),B=t(87843),L=t(28065),T=(t(21052),t(3478),t(80184)),N={},H=function(e){if(N[e])return N[e];if(e.startsWith("Slackbot"))return N[e]="Slack",N[e];if(e.startsWith("Discord"))return N[e]="Discord",N[e];var n=new(C())(e),t=n.getOS(),r=n.getBrowser();return N[e]="".concat(r.name," / ").concat(t.name),N[e]},F=[{id:"created_at",label:"Time",format:function(e){return z().utc(e).local().fromNow()}},{id:"name",label:"Name"},{id:"type",label:"Type"},{id:"session_key",label:"Session"},{id:"request_user_email",label:"User"},{id:"request_location",label:"Location"},{id:"response_time",label:"Time",format:function(e){return"".concat(e.toFixed(2),"s")}},{id:"response_status",label:"Status"}],Y=function(e){var n=e.label,t=e.value,r=e.content_type,i=void 0===r?null:r,a=(0,S.useMemo)((function(){if("text/markdown"===i)return(0,T.jsx)(M.Z,{children:t});if("application/json"===i){var e=t.replace(/'/g,'"').replace(/None/g,"null").replace(/True/g,"true").replace(/False/g,"false");try{e=JSON.stringify(JSON.parse(e),null,2)}catch(n){}return(0,T.jsx)(A.ZP,{mode:"json",theme:"chrome",value:e,readOnly:!0,width:"100%",height:"200px",showPrintMargin:!1,showLineNumbers:!1,showGutter:!1,onLoad:function(e){var n=function(){var n=e.getSession().getLength()*e.renderer.lineHeight,t=Math.min(n,200);e.container.style.height="".concat(t,"px"),e.resize()};e.setOption("showGutter",!1),e.getSession().on("change",n),n()}})}return(0,T.jsx)(o.Z,{variant:"body2",sx:{whiteSpace:"pre-wrap",wordBreak:"break-all",color:"#1b5c85"},children:t})}),[t,i]);return(0,T.jsxs)(s.Z,{children:[(0,T.jsx)(o.Z,{variant:"caption",style:{fontWeight:600,color:"gray"},children:n}),a]})},D=function(e){var n=e.apps,t=e.sessions,r=e.users,o=e.onFilter,p=(0,S.useState)(null),f=(0,a.Z)(p,2),m=f[0],h=f[1],x=(0,S.useState)(null),g=(0,a.Z)(x,2),v=g[0],Z=g[1],_=(0,S.useState)(null),j=(0,a.Z)(_,2),b=j[0],y=j[1];return(0,T.jsxs)(l.Z,{direction:"row",spacing:1,sx:{padding:"10px"},children:[(0,T.jsx)(u.Z,{id:"app-selector",sx:{width:250},options:n,autoHighlight:!0,getOptionLabel:function(e){return e.name||""},renderInput:function(e){return(0,T.jsx)(c.Z,(0,i.Z)((0,i.Z)({},e),{},{size:"small",label:"App",inputProps:(0,i.Z)((0,i.Z)({},e.inputProps),{},{autoComplete:"new-password"})}))},renderOption:function(e,n){return(0,T.jsx)(s.Z,(0,i.Z)((0,i.Z)({component:"li",sx:{fontSize:14,"& > span":{marginRight:2,fontSize:18}}},e),{},{children:n.name}))},onChange:function(e,n){h(n)}}),(0,T.jsx)(u.Z,{id:"session-selector",sx:{width:300},options:t,autoHighlight:!0,getOptionLabel:function(e){return e.name||""},renderInput:function(e){return(0,T.jsx)(c.Z,(0,i.Z)((0,i.Z)({},e),{},{size:"small",label:"Session",inputProps:(0,i.Z)((0,i.Z)({},e.inputProps),{},{autoComplete:"new-password"})}))},renderOption:function(e,n){return(0,T.jsx)(s.Z,(0,i.Z)((0,i.Z)({component:"li",sx:{fontSize:14,"& > span":{marginRight:2,fontSize:18}}},e),{},{children:n.name}))},isOptionEqualToValue:function(e,n){return e.name===n.name},onChange:function(e,n){Z(n)}}),(0,T.jsx)(u.Z,{id:"user-selector",sx:{width:250},options:r,autoHighlight:!0,getOptionLabel:function(e){return e.name||""},renderInput:function(e){return(0,T.jsx)(c.Z,(0,i.Z)((0,i.Z)({},e),{},{size:"small",label:"User",inputProps:(0,i.Z)((0,i.Z)({},e.inputProps),{},{autoComplete:"new-password"})}))},renderOption:function(e,n){return(0,T.jsx)(s.Z,(0,i.Z)((0,i.Z)({component:"li",sx:{fontSize:14,"& > span":{marginRight:2,fontSize:18}}},e),{},{children:n.name}))},isOptionEqualToValue:function(e,n){return e.name===n.name},onChange:function(e,n){y(n)}}),(0,T.jsx)(d.Z,{type:"primary",style:{textTransform:"none"},variant:"contained",onClick:function(){o({app_uuid:(null===m||void 0===m?void 0:m.uuid)||null,session_key:(null===v||void 0===v?void 0:v.name)||null,request_user_email:(null===b||void 0===b?void 0:b.name)||null,endpoint_uuid:null})},children:"Filter"})]})};function U(e){var n=e.filter,t=e.filteredColumns,o=e.showFilterBar,u=(0,R.sJ)(E.C_),c=(0,S.useState)([]),d=(0,a.Z)(c,2),k=d[0],A=d[1],P=(0,S.useState)({}),C=(0,a.Z)(P,2),M=C[0],N=C[1],U=(0,S.useState)(!1),V=(0,a.Z)(U,2),W=V[0],J=V[1],G=(0,S.useState)(null),X=(0,a.Z)(G,2),K=X[0],Q=X[1],$=(0,S.useState)(n||{page:1}),ee=(0,a.Z)($,2),ne=ee[0],te=ee[1],re=(0,S.useMemo)((function(){return F.filter((function(e){return!t||t.includes(e.id)}))}),[t]),ie=function(e,n){var t,r=n[e.id];if("name"===e.id)return null!==n.app_uuid?(null===(t=u.find((function(e){return e.uuid===n.app_uuid})))||void 0===t?void 0:t.name)||"Deleted App":"Playground";if("type"===e.id)return(0,T.jsx)(p.Z,{title:null!==n.app_uuid?"App":"Endpoint",children:null!==n.app_uuid?(0,T.jsx)(q.Z,{sx:{color:"#999"},size:"small"}):(0,T.jsx)(O.Z,{sx:{color:"#999"},size:"small"})});if("request_user_email"===e.id){var i,a,o,l,c,d,h,x;if(null!==(i=n.platform_data)&&void 0!==i&&null!==(a=i.slack)&&void 0!==a&&a.user_email)return(0,T.jsxs)(s.Z,{children:[(0,T.jsx)(f.Z,{component:L.r,fontSize:"8",sx:{marginRight:"5px",color:"#555",verticalAlign:"middle"}}),null===(c=n.platform_data)||void 0===c||null===(d=c.slack)||void 0===d?void 0:d.user_email]});if(null!==(o=n.platform_data)&&void 0!==o&&null!==(l=o.discord)&&void 0!==l&&l.global_name)return(0,T.jsxs)(s.Z,{children:[(0,T.jsx)(f.Z,{component:B.r,fontSize:"8",sx:{marginRight:"5px",color:"#555",verticalAlign:"middle"}}),null===(h=n.platform_data)||void 0===h||null===(x=h.discord)||void 0===x?void 0:x.global_name]});if(null===n.request_user_email||""===n.request_user_email)return"Anonymous"}else{if("request_location"===e.id&&(null===n.request_location||""===n.request_location))return"Unknown";if("response_status"===e.id)return(0,T.jsx)(m.Z,{size:"small",label:n.response_status,color:n.response_status<300?"success":"error",sx:{borderRadius:"5px"}});if("created_at"===e.id)return(0,T.jsx)(p.Z,{title:z().utc(r).local().format("D-MMM-YYYY h:mm:ss A"),children:(0,T.jsx)("span",{children:e.format?e.format(r):r})})}return e.format?e.format(r):r};return(0,S.useEffect)((function(){J(!0),(0,I.o)().get("/api/history?".concat(Object.keys(ne).map((function(e){return"".concat(e,"=").concat(ne[e])})).join("&"))).then((function(e){var n,t;Q(null===(n=e.data)||void 0===n?void 0:n.count),A(((null===(t=e.data)||void 0===t?void 0:t.results)||[]).map((function(e){return(0,i.Z)((0,i.Z)({},e),{},{expand:!1})})))})).catch((function(e){console.log(e)})).finally((function(){J(!1)}))}),[K,ne]),(0,T.jsx)(h.ZP,{container:!0,spacing:1,children:(0,T.jsxs)(x.Z,{sx:{padding:"10px 20px"},children:[o&&(0,T.jsxs)(s.Z,{children:[(0,T.jsx)(D,{apps:u,sessions:Array.from(new Set(k.filter((function(e){return null!==e.session_key&&""!==e.session_key})).map((function(e){return e.session_key})))).map((function(e){return{name:e}})),users:Array.from(new Set(k.filter((function(e){return null!==e.request_user_email&&""!==e.request_user_email})).map((function(e){return e.request_user_email})))).map((function(e){return{name:e}})),onFilter:function(e){return te((0,i.Z)((0,i.Z)({},e),{page:1}))}}),(0,T.jsx)(g.Z,{})]}),W&&(0,T.jsx)("span",{children:"Loading"}),(0,T.jsxs)(v.Z,{stickyHeader:!0,"aria-label":"sticky table",children:[(0,T.jsx)(Z.Z,{children:(0,T.jsx)(_.Z,{children:re.map((function(e){return(0,T.jsx)(j.Z,{align:e.align,style:{fontWeight:"bold",textAlign:"left"},children:e.label},e.id)}))})}),(0,T.jsx)(b.Z,{children:k.map((function(e){return[(0,T.jsx)(_.Z,{hover:!0,role:"checkbox",tabIndex:-1,sx:{cursor:"pointer",backgroundColor:e.expand?"#f5f5f5":"inherit"},onClick:function(){return function(e){A(k.map((function(n){return n.request_uuid===e.request_uuid?(0,i.Z)((0,i.Z)({},n),{},{expand:!n.expand}):n}))),M[e.request_uuid]||(0,I.o)().get("/api/history/".concat(e.request_uuid)).then((function(n){N((0,i.Z)((0,i.Z)({},M),{},(0,r.Z)({},e.request_uuid,n.data)))}))}(e)},children:re.map((function(n){return(0,T.jsx)(j.Z,{align:n.align,style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:ie(n,e)},n.id)}))},e.request_uuid),(0,T.jsx)(_.Z,{children:(0,T.jsx)(j.Z,{style:{paddingBottom:0,paddingTop:0,border:0},colSpan:12,children:(0,T.jsx)(y.Z,{in:e.expand,timeout:"auto",unmountOnExit:!0,children:(0,T.jsxs)(s.Z,{sx:{margin:1},children:[!M[e.request_uuid]&&"Loading...  ",M[e.request_uuid]&&(0,T.jsxs)(h.ZP,{container:!0,spacing:1,sx:{marginBottom:1,border:"1px solid #eee"},children:[(0,T.jsx)(h.ZP,{item:!0,xs:12,md:6,sx:{borderRight:"solid 1px #eee"},children:(0,T.jsxs)(l.Z,{direction:"column",spacing:1,sx:{marginBottom:1},children:[(0,T.jsx)(Y,{label:"Request",value:e.request_uuid}),e.app_uuid&&(0,T.jsx)(Y,{label:"Session",value:M[e.request_uuid].session_key}),(0,T.jsx)(Y,{label:"IP Address",value:M[e.request_uuid].request_ip}),(0,T.jsx)(Y,{label:"Platform",value:H(e.request_user_agent)}),(0,T.jsx)(Y,{label:"User Agent",value:M[e.request_uuid].request_user_agent})]})}),(0,T.jsx)(h.ZP,{item:!0,xs:12,md:6,children:(0,T.jsxs)(l.Z,{direction:"column",spacing:1,sx:{marginBottom:1},children:[(0,T.jsx)(Y,{label:"Request",value:M[e.request_uuid].request_body,content_type:M[e.request_uuid].request_content_type}),(0,T.jsx)(Y,{label:"Response",value:M[e.request_uuid].response_body,content_type:M[e.request_uuid].response_content_type})]})})]})]})})})},"".concat(e.request_uuid,"_details"))]}))})]}),(0,T.jsx)(w.Z,{count:Math.ceil((K||0)/20),variant:"outlined",shape:"rounded",page:ne.page,onChange:function(e,n){te((0,i.Z)((0,i.Z)({},ne),{},{page:n}))},sx:{marginTop:2,float:"right"}})]})})}}}]);
//# sourceMappingURL=2909.b4c85389.chunk.js.map